<template>
  <figure class="user-profile-card">
    <img :src="profileData.imageUrl" :alt="profileData.name" />
    <figcaption>
      <img :src="profileData.profilePicUrl" :alt="profileData.name + ' Profile'" class="profile" />
      <h2>{{ profileData.name }}<span>{{ profileData.jobTitle }}</span></h2>
      <p>{{ profileData.description }}</p>
      <a v-if="showFollowButton" href="#" class="follow" @click.prevent="handleFollowClick">Follow</a>
      <a href="#" class="info" @click.prevent="handleInfoClick">More Info</a>
    </figcaption>
  </figure>
</template>

<script setup>
// 定义组件接收的属性类型
defineProps({
  profileData: {
    type: Object,
    required: true
  },
  showFollowButton: {
    type: Boolean,
    default: true
  }
});

// 模拟关注按钮点击事件处理函数（实际需根据业务逻辑完善）
const handleFollowClick = () => {
  alert('关注按钮被点击，这里可添加实际关注逻辑');
};

// 模拟更多信息按钮点击事件处理函数（实际需根据业务逻辑完善）
const handleInfoClick = () => {
  alert('更多信息按钮被点击，这里可添加跳转到详情页等实际逻辑');
};
</script>

<style lang="scss" scoped>
@import url(https://fonts.googleapis.com/css?family=Roboto:300,400,600);

// 定义组件样式相关变量
$primary-color: #ffffff;
$highlight-color: #2980b9;
$bg-color: #141414;
$shadow-color: rgba(0, 0, 0, 0.3);
$border-width: 1px;

.user-profile-card {
  font-family: 'Roboto', Arial, sans-serif;
  position: relative;
  overflow: hidden;
  margin: 10px;
  min-width: 230px;
  max-width: 315px;
  width: 100%;
  color: $primary-color;
  text-align: left;
  line-height: 1.4em;
  background-color: $bg-color;

  // 确保所有子元素继承盒模型设置和过渡效果
  * {
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
    -webkit-transition: all 0.25s ease;
    transition: all 0.25s ease;
  }

  img {
    max-width: 100%;
    vertical-align: top;
    opacity: 0.85;
  }

  figcaption {
    width: 100%;
    background-color: $bg-color;
    padding: 25px;
    position: relative;

    &:before {
      position: absolute;
      content: '';
      bottom: 100%;
      left: 0;
      width: 0;
      height: 0;
      border-style: solid;
      border-width: 55px 0 0 400px;
      border-color: transparent transparent transparent $bg-color;
    }

    a {
      padding: 5px;
      border: $border-width solid $primary-color;
      color: $primary-color;
      font-size: 0.7em;
      text-transform: uppercase;
      margin: 10px 0;
      display: inline-block;
      opacity: 0.65;
      width: 47%;
      text-align: center;
      text-decoration: none;
      font-weight: 600;
      letter-spacing: 1px;

      &:hover {
        opacity: 1;
      }
    }
  }

  // 头像样式
  .profile {
    border-radius: 50%;
    position: absolute;
    bottom: 100%;
    left: 25px;
    z-index: 1;
    max-width: 90px;
    opacity: 1;
    box-shadow: 0 0 15px $shadow-color;
  }

  // 关注按钮特定样式
  .follow {
    margin-right: 4%;
    border-color: $highlight-color;
    color: $highlight-color;
  }

  h2 {
    margin: 0 0 5px;
    font-weight: 300;
  }

  h2 span {
    display: block;
    font-size: 0.5em;
    color: $highlight-color;
  }

  p {
    margin: 0 0 10px;
    font-size: 0.8em;
    letter-spacing: 1px;
    opacity: 0.8;
  }
}
</style>